package org.example.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.utils.FileUtil;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags ="文件管理")
@RequestMapping("file")
@RestController
public class FileController {

    @ApiOperation("普通文件流")
    @PutMapping("1")
    public String s1(String src,String target){
        FileUtil.copyFile(src, target);
        return "ok1";
    }

    @ApiOperation("buffer文件流")
    @PutMapping("2")
    public String s2(String src,String target){
        FileUtil.copyFileBuffer(src, target);
        return "ok2";
    }
    @ApiOperation("JVM缓冲区")
    @PutMapping("3")
    public String fileCopyNIO(String src,String target){
        FileUtil.fileCopyNIO(src, target);
        return "ok3";
    }
    @ApiOperation("零拷贝")
    @PutMapping("4")
    public String s4(String src,String target){
        FileUtil.fileCopyNIO2(src, target);
        return "ok4";
    }
    @ApiOperation("内存映射文件")
    @PutMapping("5")
    public String s5(String src,String target){
        FileUtil.fileCopyMemoryMapping(src, target);
        return "ok5";
    }

}
